package com.luis.demo.controller;

import com.luis.demo.entity.Five;
import com.luis.demo.repository.FiveRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;

@Controller
@RequestMapping("/five")
public class LoginController {

    @Autowired
    private FiveRepository fiveRepository;

    @GetMapping("/findAll")
    public Collection<Five> findAll(Model model){
        fiveRepository.findAll()
        model
        return ;
    }

    @GetMapping("/save/{id}")
    public Five findById(@PathVariable("id")Long id){
        return fiveRepository.findById(id);
    }

    @PostMapping("/save")
    public void save(@RequestBody Five fIve){
        fiveRepository.saveOrUpdate(fIve);
    }

    @DeleteMapping("/deleteById/{id}")
    public void deleteById(@PathVariable("id") Long id){
        fiveRepository.deleteById(id);
    }

    @PutMapping("/update")
    public void update(@RequestBody Five five){
        fiveRepository.saveOrUpdate(five);
    }
    @PostMapping("/test")
    public void test(String username,String password){

    }
}
